Listing 10 - Page 0: No Title

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 10\10.1467 - No Title.py
# Description: No Title
##############################################################################

class PhoneType(UniqueList):
    def __init__(self):
        super().__init__(PhoneType)
class Phonebook(UniqueList):
    def __init__(self):
        super().__init__(PhonebookData)
        self.phone_types = PhoneTypes()
    def add_type(self, type):
        self.phone_types.add(PhoneType(type))
    def search_name(self, name):
        if isinstance(name, str):
            name = Name(name)
        for data in self.list:
            if data.name == name:
                return data
        else:
            return None
    def sort(self):
        super().sort(lambda data: str(data.name))
Click here to download the file